<?php
require_once "statics.php";
require_once "functions.php";
if(isset($_GET['check_email']))
{
    $rsMail=rsSelect("email","member",array("email=",$_GET['check_email']));
    if(is_string($rsMail))
    {
        echo $rsMail . "ERROR CODE: 0" . __LINE__;
        exit();
    }
    if(mysql_num_rows($rsMail) == 0)
    {
        echo "0";
        exit();
    }
    $sNewPass=createRandomPassword();
    $sHashedNewPass=sHashNewPassword($_GET['check_email'],$sNewPass);
    $iRet=iUpdate("member",array("password"=>$sHashedNewPass),array("email=",$_GET['check_email']));
    if(is_string($iRet))
    {
        echo $iRet.__LINE__;
        exit();
    }
    $to=$_GET['check_email'];
    $subject="New password";
    $message="This is a random generated password in response to your request for resetting your password: ".$sNewPass;
    $from="From: postmaster@Confo.com";
    $bRet=mail($to,$subject,$message,$from) or die("MAIL SERVER ERROR CODE 0" . __LINE__);
    if(!$bRet)
    {
        echo "MAIL SERVER ERROR CODE 0" . __LINE__;
        exit();
    }
    echo "1";
}
?>
